//
//  BaoGongDanViewController.m
//  BaoGongBao
//
//  Created by User on 14/11/13.
//  Copyright (c) 2014年 irule. All rights reserved.
//

#import "BaoGongDanViewController.h"

@interface BaoGongDanViewController ()
{
}

@end

@implementation BaoGongDanViewController
//
//- (void)barButtonItemSelector:(UIBarButtonItem *)sender
//{
//	switch (sender.tag)
//	{
//		case kBaoGongDanViewControllerType_SpareParts:
//		{
//self.title = sender.title;
//		}
//			break;
//
//		case kBaoGongDanViewControllerType_Merchandiser:
//		{
//			self.title = sender.title;
//
//		}
//			break;
//
//		default:
//		{
//		}
//			break;
//			
//	}
//}

- (void)viewDidLoad {
    [super viewDidLoad];
	// Do any additional setup after loading the view.
//	self.navigationController.toolbarHidden = NO;
	// Segmented Control #1
	self.edgesForExtendedLayout = UIRectEdgeNone;
	self.view.backgroundColor = [UIColor whiteColor];


	// 1
	m_hv1_tfDingDanHao = @"";

	// 2
	m_hv2_tfDingDanHao = @"";
	m_hv2_tfTianShu = @"当天";
	m_hv2_tfZhuangTai = @"";

	// 3
	m_hv3_tfDingDanHao = @"";

	// 4
	m_hv4_tfDingDanHao = @"";

	// 5
	m_hv5_tfDingDanHao = @"";
	m_hv5_tfTianShu = @"当天";
	m_hv5_tfZhuangTai = @"";

	// 6
	m_hv6_tfDingDanHao = @"";


	PPiFlatSegmentedControl *segmented=[[PPiFlatSegmentedControl alloc] initWithFrame:CGRectMake(0, 0, 320, 44) items:
  										@[@{@"text":@"完工报工"},
										@{@"text":@"记录查询"},
										@{@"text":@"同步设置"}] iconPosition:IconPositionRight andSelectionBlock:^(NSUInteger segmentIndex)
										{
											[self.mViewInput resignFirstResponder];
											switch (segmentIndex)
											{
												case kBaoGongDanViewControllerTab_WanGongBaoGong:
												{
													self.mBaoGongDanViewControllerTab = kBaoGongDanViewControllerTab_WanGongBaoGong;
													switch (self.mBaoGongDanViewControllerType) {
														case kBaoGongDanViewControllerType_SpareParts:
														{
															self.v1.hidden = NO;
															[self.tvSpareParts_WanGongBaoGong reloadData];
															self.v2.hidden = YES;
															self.v3.hidden = YES;
															self.v4.hidden = YES;
															self.v5.hidden = YES;
															self.v6.hidden = YES;
														}
															break;

														case kBaoGongDanViewControllerType_Merchandiser:
														{
															self.v1.hidden = YES;
															self.v2.hidden = YES;
															self.v3.hidden = YES;
															self.v4.hidden = NO;
															[self.tvMerchandiser_WanGongBaoGong reloadData];
															self.v5.hidden = YES;
															self.v6.hidden = YES;
														}
															break;

														default:
															break;
													}
												}
													break;

												case kBaoGongDanViewControllerTab_JiLuChaXun:
												{
													self.mBaoGongDanViewControllerTab = kBaoGongDanViewControllerTab_JiLuChaXun;

													switch (self.mBaoGongDanViewControllerType) {
														case kBaoGongDanViewControllerType_SpareParts:
														{
															self.v1.hidden = YES;
															self.v2.hidden = NO;
															[self.tvSpareParts_JiLuChaXun reloadData];
															self.v3.hidden = YES;
															self.v4.hidden = YES;
															self.v5.hidden = YES;
															self.v6.hidden = YES;
														}
															break;

														case kBaoGongDanViewControllerType_Merchandiser:
														{
															self.v1.hidden = YES;
															self.v2.hidden = YES;
															self.v3.hidden = YES;
															self.v4.hidden = YES;
															self.v5.hidden = NO;
															[self.tvMerchandiser_JiLuChaXun reloadData];
															self.v6.hidden = YES;
														}
															break;

														default:
															break;
													}
												}
													break;

												case kBaoGongDanViewControllerTab_TongBuSheZhi:
												{
													self.mBaoGongDanViewControllerTab = kBaoGongDanViewControllerTab_TongBuSheZhi;

													switch (self.mBaoGongDanViewControllerType) {
														case kBaoGongDanViewControllerType_SpareParts:
														{
															self.v1.hidden = YES;
															self.v2.hidden = YES;
															self.v3.hidden = NO;
															[self.tvSpareParts_TongBuSheZhi reloadData];
															self.v4.hidden = YES;
															self.v5.hidden = YES;
															self.v6.hidden = YES;
														}
															break;

														case kBaoGongDanViewControllerType_Merchandiser:
														{
															self.v1.hidden = YES;
															self.v2.hidden = YES;
															self.v3.hidden = YES;
															self.v4.hidden = YES;
															self.v5.hidden = YES;
															self.v6.hidden = NO;
															[self.tvMerchandiser_TongBuSheZhi reloadData];
														}
															break;

														default:
															break;
													}
												}
													break;

												default:
													break;
											}

										}];
	segmented.color=[UIColor colorWithRed:88.0f/255.0 green:88.0f/255.0 blue:88.0f/255.0 alpha:1];
	segmented.borderWidth=0.5;
	segmented.borderColor=[UIColor darkGrayColor];
	segmented.selectedColor=[UIColor colorWithRed:0.0f/255.0 green:141.0f/255.0 blue:176.0f/255.0 alpha:1];
	segmented.textAttributes=@{NSFontAttributeName:[UIFont systemFontOfSize:13],
							   NSForegroundColorAttributeName:[UIColor whiteColor]};
	segmented.selectedTextAttributes=@{NSFontAttributeName:[UIFont systemFontOfSize:13],
									   NSForegroundColorAttributeName:[UIColor whiteColor]};
	[self.view addSubview:segmented];

	CGRect rect = CGRectMake(0, 44, 320, CGRectGetMaxY(self.view.frame)-CGRectGetMaxY(self.navigationController.navigationBar.frame)-44-44);
	self.v1 = [[UIView alloc] initWithFrame:rect];
	[self.view addSubview:self.v1];

	self.v2 = [[UIView alloc] initWithFrame:rect];
	[self.view addSubview:self.v2];

	self.v3 = [[UIView alloc] initWithFrame:rect];
	[self.view addSubview:self.v3];

	self.v4 = [[UIView alloc] initWithFrame:rect];
	[self.view addSubview:self.v4];

	self.v5 = [[UIView alloc] initWithFrame:rect];
	[self.view addSubview:self.v5];

	self.v6 = [[UIView alloc] initWithFrame:rect];
	[self.view addSubview:self.v6];

	self.tvSpareParts_WanGongBaoGong = [[UITableView alloc] initWithFrame:self.v1.bounds style:UITableViewStyleGrouped];
//	self.tvSpareParts_WanGongBaoGong.bounces = NO;
	[self.v1 addSubview:self.tvSpareParts_WanGongBaoGong];

	self.tvMerchandiser_WanGongBaoGong = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.v4.frame), CGRectGetHeight(self.v4.frame)-44) style:UITableViewStyleGrouped];
//	self.tvMerchandiser_WanGongBaoGong.bounces = NO;
	[self.v4 addSubview:self.tvMerchandiser_WanGongBaoGong];

	CheckBox *btn1 = [CheckBox buttonWithType:UIButtonTypeCustom];
	btn1.frame = CGRectMake(20, CGRectGetMaxY(self.tvMerchandiser_WanGongBaoGong.frame)+7, (CGRectGetWidth(self.tvMerchandiser_WanGongBaoGong.frame)-40-40)/2, 30);
	[btn1 setTitle:@"全选" forState:UIControlStateNormal];
	[btn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
	btn1.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
	[btn1 addTarget:self action:@selector(btn21selector:) forControlEvents:UIControlEventTouchUpInside];
	[btn1 setImage:[UIImage imageNamed:@"uncheck"] forState:UIControlStateNormal];
	btn1.tag = 1;
	[self.v4 addSubview:btn1];

	CheckBox *btn2 = [CheckBox buttonWithType:UIButtonTypeCustom];
	btn2.frame = CGRectMake((CGRectGetWidth(self.tvMerchandiser_WanGongBaoGong.frame)-40)/2+40, CGRectGetMaxY(self.tvMerchandiser_WanGongBaoGong.frame)+7, (CGRectGetWidth(self.tvMerchandiser_WanGongBaoGong.frame)-40-40)/2, 30);
	[btn2 setTitle:@"提交报工" forState:UIControlStateNormal];
	[btn2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
	btn2.layer.cornerRadius = 6;
	btn2.layer.borderWidth = 1;
	btn2.layer.borderColor = [UIColor lightGrayColor].CGColor;
	btn2.tag = 2;
	[btn2 addTarget:self action:@selector(btn21selector:) forControlEvents:UIControlEventTouchUpInside];
	[self.v4 addSubview:btn2];


	self.tvSpareParts_JiLuChaXun = [[UITableView alloc] initWithFrame:self.v1.bounds style:UITableViewStyleGrouped];
//	self.tvSpareParts_JiLuChaXun.bounces = NO;
	[self.v2 addSubview:self.tvSpareParts_JiLuChaXun];

	self.tvMerchandiser_JiLuChaXun = [[UITableView alloc] initWithFrame:self.v1.bounds style:UITableViewStyleGrouped];
//	self.tvMerchandiser_JiLuChaXun.bounces = NO;
	[self.v5 addSubview:self.tvMerchandiser_JiLuChaXun];

	self.tvSpareParts_TongBuSheZhi = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.v6.frame), CGRectGetHeight(self.v6.frame)-44) style:UITableViewStyleGrouped];
//	self.tvSpareParts_TongBuSheZhi.bounces = NO;
	[self.v3 addSubview:self.tvSpareParts_TongBuSheZhi];

	UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
	btn3.frame = CGRectMake(20, CGRectGetMaxY(self.tvSpareParts_TongBuSheZhi.frame)+7, CGRectGetWidth(self.tvSpareParts_TongBuSheZhi.frame)-40, 30);
	[btn3 setTitle:@"取消同步" forState:UIControlStateNormal];
	[btn3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
	btn3.layer.cornerRadius = 6;
	btn3.layer.borderWidth = 1;
	btn3.layer.borderColor = [UIColor lightGrayColor].CGColor;
	[btn3 addTarget:self action:@selector(btn3selector:) forControlEvents:UIControlEventTouchUpInside];
	[self.v3 addSubview:btn3];


	self.tvMerchandiser_TongBuSheZhi = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.v6.frame), CGRectGetHeight(self.v6.frame)-44) style:UITableViewStyleGrouped];
//	self.tvMerchandiser_TongBuSheZhi.bounces = NO;
	[self.v6 addSubview:self.tvMerchandiser_TongBuSheZhi];

	UIButton *btn6 = [UIButton buttonWithType:UIButtonTypeCustom];
	btn6.frame = CGRectMake(20, CGRectGetMaxY(self.tvMerchandiser_TongBuSheZhi.frame)+7, CGRectGetWidth(self.tvMerchandiser_TongBuSheZhi.frame)-40, 30);
	[btn6 setTitle:@"取消同步" forState:UIControlStateNormal];
	[btn6 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
	btn6.layer.cornerRadius = 6;
	btn6.layer.borderWidth = 1;
	btn6.layer.borderColor = [UIColor lightGrayColor].CGColor;
	[btn6 addTarget:self action:@selector(btn6selector:) forControlEvents:UIControlEventTouchUpInside];
	[self.v6 addSubview:btn6];

	self.tvSpareParts_WanGongBaoGong.delegate = self;
	self.tvSpareParts_WanGongBaoGong.dataSource = self;
	self.tvMerchandiser_WanGongBaoGong.delegate = self;
	self.tvMerchandiser_WanGongBaoGong.dataSource = self;
	self.tvSpareParts_JiLuChaXun.delegate = self;
	self.tvSpareParts_JiLuChaXun.dataSource = self;
	self.tvMerchandiser_JiLuChaXun.delegate = self;
	self.tvMerchandiser_JiLuChaXun.dataSource = self;
	self.tvSpareParts_TongBuSheZhi.delegate = self;
	self.tvSpareParts_TongBuSheZhi.dataSource = self;
	self.tvMerchandiser_TongBuSheZhi.delegate = self;
	self.tvMerchandiser_TongBuSheZhi.dataSource = self;

	self.mBaoGongDanViewControllerTab = kBaoGongDanViewControllerTab_WanGongBaoGong;

	PPiFlatSegmentedControl *segmented2=[[PPiFlatSegmentedControl alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.view.frame)-CGRectGetMaxY(self.navigationController.navigationBar.frame)-44, 320, 44) items:
  						@[@{@"text":@"零部件报工"},
						@{@"text":@"跟单报工"}] iconPosition:IconPositionRight andSelectionBlock:^(NSUInteger segmentIndex)
										 {
											 [self.mViewInput resignFirstResponder];
							switch (segmentIndex)
							{
								case kBaoGongDanViewControllerType_SpareParts:
								{
									self.mBaoGongDanViewControllerType = kBaoGongDanViewControllerType_SpareParts;

									switch (self.mBaoGongDanViewControllerTab) {
										case kBaoGongDanViewControllerTab_WanGongBaoGong:
										{
											self.v1.hidden = NO;
											[self.tvSpareParts_WanGongBaoGong reloadData];
											self.v2.hidden = YES;
											self.v3.hidden = YES;
											self.v4.hidden = YES;
											self.v5.hidden = YES;
											self.v6.hidden = YES;
										}
											break;

										case kBaoGongDanViewControllerTab_JiLuChaXun:
										{
											self.v1.hidden = YES;
											self.v2.hidden = NO;
											[self.tvSpareParts_JiLuChaXun reloadData];
											self.v3.hidden = YES;
											self.v4.hidden = YES;
											self.v5.hidden = YES;
											self.v6.hidden = YES;
										}
											break;

										case kBaoGongDanViewControllerTab_TongBuSheZhi:
										{
											self.v1.hidden = YES;
											self.v2.hidden = YES;
											self.v3.hidden = NO;
											[self.tvSpareParts_TongBuSheZhi reloadData];
											self.v4.hidden = YES;
											self.v5.hidden = YES;
											self.v6.hidden = YES;
										}
											break;

										default:
											break;
									}
								}
									break;
									

								case kBaoGongDanViewControllerType_Merchandiser:
								{
									self.mBaoGongDanViewControllerType = kBaoGongDanViewControllerType_Merchandiser;

									switch (self.mBaoGongDanViewControllerTab) {
										case kBaoGongDanViewControllerTab_WanGongBaoGong:
										{
											self.v1.hidden = YES;
											self.v2.hidden = YES;
											self.v3.hidden = YES;
											self.v4.hidden = NO;
											[self.tvMerchandiser_WanGongBaoGong reloadData];
											self.v5.hidden = YES;
											self.v6.hidden = YES;
										}
											break;

										case kBaoGongDanViewControllerTab_JiLuChaXun:
										{
											self.v1.hidden = YES;
											self.v2.hidden = YES;
											self.v3.hidden = YES;
											self.v4.hidden = YES;
											self.v5.hidden = NO;
											[self.tvMerchandiser_JiLuChaXun reloadData];
											self.v6.hidden = YES;
										}
											break;

										case kBaoGongDanViewControllerTab_TongBuSheZhi:
										{
											self.v1.hidden = YES;
											self.v2.hidden = YES;
											self.v3.hidden = YES;
											self.v4.hidden = YES;
											self.v5.hidden = YES;
											self.v6.hidden = NO;
											[self.tvMerchandiser_TongBuSheZhi reloadData];
										}
											break;

										default:
											break;
									}
								}
									break;
									
								default:
									break;
							}
										 }];
	segmented2.color=[UIColor whiteColor];
	segmented2.borderWidth=0.5;
	segmented2.borderColor=[UIColor colorWithRed:244.0f/255.0 green:67.0f/255.0 blue:60.0f/255.0 alpha:1];
	segmented2.selectedColor=[UIColor colorWithRed:244.0f/255.0 green:67.0f/255.0 blue:60.0f/255.0 alpha:1];
	segmented2.textAttributes=@{NSFontAttributeName:[UIFont systemFontOfSize:13],
								NSForegroundColorAttributeName:[UIColor colorWithRed:244.0f/255.0 green:67.0f/255.0 blue:60.0f/255.0 alpha:1]};
	segmented2.selectedTextAttributes=@{NSFontAttributeName:[UIFont systemFontOfSize:13],
										NSForegroundColorAttributeName:[UIColor whiteColor]};
	[self.view addSubview:segmented2];
	switch (self.mBaoGongDanViewControllerType)
	{
		case kBaoGongDanViewControllerType_SpareParts:
		{
			self.v1.hidden = NO;
			self.v2.hidden = YES;
			self.v3.hidden = YES;
			self.v4.hidden = YES;
			self.v5.hidden = YES;
			self.v6.hidden = YES;

			self.mBaoGongDanViewControllerTab = kBaoGongDanViewControllerTab_WanGongBaoGong;

			[segmented setEnabled:YES forSegmentAtIndex:0];
			[segmented2 setEnabled:YES forSegmentAtIndex:0];
		}
			break;

		case kBaoGongDanViewControllerType_Merchandiser:
		{
			self.v1.hidden = YES;
			self.v2.hidden = YES;
			self.v3.hidden = YES;
			self.v4.hidden = NO;
			self.v5.hidden = YES;
			self.v6.hidden = YES;

			self.mBaoGongDanViewControllerTab = kBaoGongDanViewControllerTab_WanGongBaoGong;

			[segmented setEnabled:YES forSegmentAtIndex:0];
			[segmented2 setEnabled:YES forSegmentAtIndex:1];
		}
			break;

		default:
			break;
	}

	self.vPop = [[UIView alloc] initWithFrame:CGRectMake(40, 40, CGRectGetWidth(self.view.frame)-80, CGRectGetHeight(self.view.frame)-180)];
	[self.view addSubview:self.vPop];
	self.table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.vPop.frame), CGRectGetHeight(self.vPop.frame)-44) style:UITableViewStylePlain];
	self.table.delegate = self;
	self.table.dataSource = self;
	[self.vPop addSubview:self.table];
	UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
	[bt setTitle:@"取消" forState:UIControlStateNormal];
	[bt setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
	[bt addTarget:self action:@selector(selector) forControlEvents:UIControlEventTouchUpInside];
	bt.frame = CGRectMake(20, CGRectGetMaxY(self.table.frame)-7, CGRectGetWidth(self.table.frame)-40, 30);
	[self.vPop addSubview:bt];
	bt.layer.cornerRadius= 6;
	bt.layer.borderWidth = 1;
	bt.layer.borderColor = [UIColor lightGrayColor].CGColor;
	self.vPop.layer.cornerRadius= 6;
	self.vPop.layer.borderWidth = 1;
	self.vPop.layer.borderColor = [UIColor lightGrayColor].CGColor;
	self.vPop.backgroundColor = [UIColor whiteColor];
	self.vPop.hidden = YES;
	self.v4.userInteractionEnabled = YES;

	m_hv3_guid = [NSMutableArray array];
	m_hv6_guid = [NSMutableArray array];
}

- (void)selector
{
	self.vPop.hidden = YES;
}

- (void)btn21selector:(CheckBox *)sender
{
	[self.mViewInput resignFirstResponder];
	switch (sender.tag) {
  case 1:
		{
			if (sender.bCheck) {
    sender.bCheck = NO;
				[sender setImage:[UIImage imageNamed:@"uncheck"] forState:UIControlStateNormal];
				for (NSMutableDictionary *item in self.mArrTemp) {
					[item setObject:@"0" forKey:@"check"];
				}
			} else {

    sender.bCheck = YES;
				[sender setImage:[UIImage imageNamed:@"check"] forState:UIControlStateNormal];
				for (NSMutableDictionary *item in self.mArrTemp) {
					[item setObject:@"1" forKey:@"check"];
				}
			}
		}
			break;
case 2:
		{
			if ([m_hv4_tfDingDanHao isEqualToString:@""]) {
				UIAlertView *AlertView = [[UIAlertView alloc] initWithTitle:nil message:@"请输入订单号" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
				[AlertView show];
				return;
			}
			if (!m_hv4_bSearch) {

				UIAlertView *AlertView = [[UIAlertView alloc] initWithTitle:nil message:@"请先搜索后再提交" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
				[AlertView show];
				return;
			}
			UIAlertView *AlertView = [[UIAlertView alloc] initWithTitle:nil message:@"订单号已改变，请重新搜索" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
			[AlertView show];
		}
			break;
  default:
			break;
	}
}

- (void)btn3selector:(id)sender
{
	[self.mViewInput resignFirstResponder];
	if ([m_hv6_guid count]<=0) {

		UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"请选择要同步的工单" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
		[alertView show];

		return;
	}
	NSMutableArray *arrguid = [NSMutableArray array];
	for (NSDictionary *item in m_hv3_guid) {
		[arrguid addObject:[item objectForKey:@"GUID"]];
	}
	NSDictionary *dictionary = @{@"List" : arrguid,
								 @"AUFNR": [[m_hv3_guid objectAtIndex:0] objectForKey:@"AUFNR"],
								 @"VORNR": [[m_hv3_guid objectAtIndex:0] objectForKey:@"VORNR"]
								 };

	MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
	hub.detailsLabelText = kNRStr_LoadingData;
	[[NetWorkRequestApi sharedNetWorkRequestApi] SyncPartWork:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
		NSLog(@"%@", responseObject);
		switch ([[responseObject objectForKey:@"Tag"] integerValue]) {
			case 0:
			{
				[[iToast makeText:@"同步成功"] show];


				NSDictionary *dictionary = @{
											 @"ISSUCCESS"	: @"E",
											 @"EDATE"	: @"",
											 @"AUFNR"	: m_hv3_tfDingDanHao,
											 @"BDATE"	: @""
											 };

				MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
				hub.detailsLabelText = kNRStr_LoadingData;
				[[NetWorkRequestApi sharedNetWorkRequestApi] SearchPartWork:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
					NSLog(@"%@", responseObject);
					switch ([[responseObject objectForKey:@"Tag"] integerValue]) {
						case 1:
						{
							[hub hide:YES];
							self.mArrData3 = [responseObject objectForKey:@"PartInfo"];
							[self.tvSpareParts_TongBuSheZhi reloadData];
						}
							break;
						default:
							break;
					}
				} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

					[[iToast makeText:kNRStr_LoadDataFailure] show];
				}];
			}
				break;
			default:
				break;
		}
	} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

		[[iToast makeText:kNRStr_LoadDataFailure] show];
	}];
}

- (void)btn6selector:(id)sender
{
	[self.mViewInput resignFirstResponder];
	if ([m_hv6_guid count]<=0) {

		UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"请选择要同步的工单" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
		[alertView show];

		return;
	}
	NSMutableArray *arrguid = [NSMutableArray array];
	for (NSDictionary *item in m_hv6_guid) {
		[arrguid addObject:[item objectForKey:@"GUID"]];
	}
	NSDictionary *dictionary = @{@"List" : arrguid,
								 @"AUFNR": [[m_hv6_guid objectAtIndex:0] objectForKey:@"AUFNR"],
								 @"VORNR": [[m_hv6_guid objectAtIndex:0] objectForKey:@"VORNR"]
				   };

	MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
	hub.detailsLabelText = kNRStr_LoadingData;
	[[NetWorkRequestApi sharedNetWorkRequestApi] SyncForkmanWork:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
		NSLog(@"%@", responseObject);
		switch ([[responseObject objectForKey:@"Tag"] integerValue]) {
			case 0:
			{
				[[iToast makeText:@"同步成功"] show];

				//							http://220.178.74.185:17777/hmp_002/api/SearchForkmanWork?Token=f2b6ea1ece0a47748fc00bd228b21b78   searchParas:{"ISSUCCESS":"E","EDATE":"","AUFNR":"","BDATE":""}
				NSDictionary *dictionary = @{
											 @"ISSUCCESS"	: @"E",
											 @"EDATE"	: @"",
											 @"AUFNR"	: m_hv6_tfDingDanHao,
											 @"BDATE"	: @""
											 };
				[[NetWorkRequestApi sharedNetWorkRequestApi] SearchForkmanWork:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
					NSLog(@"%@", responseObject);
					switch ([[responseObject objectForKey:@"Tag"] integerValue]) {
						case 1:
						{
							[hub hide:YES];
							//										[[iToast makeText:[responseObject objectForKey:@"Message"]] show];
							self.mArrData6 = [responseObject objectForKey:@"Result"];
							[self.tvMerchandiser_TongBuSheZhi reloadData];
						}
							break;
						default:
							break;
					}
				} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

					[[iToast makeText:kNRStr_LoadDataFailure] show];
				}];


			}
				break;
			default:
				break;
		}
	} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

		[[iToast makeText:kNRStr_LoadDataFailure] show];
	}];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark - Table View

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
	return 1;
	//	return [[self.fetchedResultsController sections] count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
	//	id <NSFetchedResultsSectionInfo> sectionInfo = [self.fetchedResultsController sections][section];
	//	return [sectionInfo numberOfObjects];
	if (tableView== self.table) {

		return [self.mArrTemp count];
	}
	switch (self.mBaoGongDanViewControllerType) {
		case kBaoGongDanViewControllerType_SpareParts:
		{
			switch (self.mBaoGongDanViewControllerTab) {
				case kBaoGongDanViewControllerTab_WanGongBaoGong:
				{
					return 3;
				}
					break;


				case kBaoGongDanViewControllerTab_JiLuChaXun:
				{
					return [self.mArrData2 count];

				}
					break;


				case kBaoGongDanViewControllerTab_TongBuSheZhi:
				{
					return [self.mArrData3 count];
				}
					break;

				default:
					break;
			}
		}
			break;
		case kBaoGongDanViewControllerType_Merchandiser:
		{

			switch (self.mBaoGongDanViewControllerTab) {
				case kBaoGongDanViewControllerTab_WanGongBaoGong:
				{
					return [self.mArrTemp count];

				}
					break;


				case kBaoGongDanViewControllerTab_JiLuChaXun:
				{
					return [self.mArrData5 count];

				}
					break;


				case kBaoGongDanViewControllerTab_TongBuSheZhi:
				{
					return [self.mArrData6 count];

				}
					break;

				default:
					return 0;
					break;
			}
		}
			break;

		default:
			return 0;
			break;
	}
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
	if (self.tvSpareParts_WanGongBaoGong == tableView)
	{
		return 238;
	}
	else if (self.tvSpareParts_JiLuChaXun == tableView)
	{
		return 190;
	}
	else if (self.tvSpareParts_TongBuSheZhi == tableView)
	{
		return 80;
	}
	else if (self.tvMerchandiser_WanGongBaoGong == tableView)
	{
		return 238;
	}
	else if (self.tvMerchandiser_JiLuChaXun == tableView)
	{
		return 190;
	}
	else if (self.tvMerchandiser_TongBuSheZhi == tableView)
	{
		return 80;
	}
	else
	{
		return 0;
	}
}

- (void)SearchSelector:(UIButton *)sender
{
	[self.mViewInput resignFirstResponder];
	NSString *order=m_hv2_tfDingDanHao;
	NSString *end = nil;
	NSString *day = self.hv2.tfTianShu.text;
	NSString *star = [[NSDate date] dateWithNOTimeString];
	NSString *status = @"E";

//searchRecord url:http://220.178.74.185:17777/hmp_002/api/SearchPartWork?Token=80fe649391924eada276117f1302ed8e  order:  day:当天  status:  star:2014-12-02   end:2014-12-02
//searchRecord url:http://220.178.74.185:17777/hmp_002/api/SearchPartWork?Token=80fe649391924eada276117f1302ed8e  order:  day:当天  status:E  star:2014-12-02   end:2014-12-02

	NSDictionary *dictionary = nil;
	if ([self.hv2.tfTianShu.text isEqualToString: @"当天"]) {
		end =[[NSDate date] dateWithNOTimeString];
	}
	else if ([self.hv2.tfTianShu.text isEqualToString: @"三天"]) {
		end=[[NSDate dateWithTimeInterval:-3*24*60*60 sinceDate:[NSDate date]] dateWithNOTimeString];
	}
	else if ([self.hv2.tfTianShu.text isEqualToString: @"一周"]) {
		end=[[NSDate dateWithTimeInterval:-7*24*60*60 sinceDate:[NSDate date]] dateWithNOTimeString];
	}
	else
	{
		end = @"";
	}
	day = self.hv2.tfTianShu.text;

	if ([self.hv2.tfZhuangTai.text isEqualToString: @"已同步"]) {
		status = @"S";
	}
	else if ([self.hv2.tfZhuangTai.text isEqualToString: @"待同步"]) {
		status = @"E";
	}
	else if ([self.hv2.tfZhuangTai.text isEqualToString: @"已取消"]) {
		status = @"X";
	} else {
		status = @"";
	}
	dictionary = @{
				   @"AUFNR"	: order,
				   @"EDATE"	: end,
				   @"BDATE"	: star,
				   @"ISSUCCESS" : status
				   };
	MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
	hub.detailsLabelText = kNRStr_LoadingData;
//searchRecord url:ht tp://220.178.74.185:17777/hmp_002/api/SearchPartWork?Token=9659ae45d6ac4d35b8d6ef585c1dbfb4  order:  day:当天  status:  star:2014-12-03   end:2014-12-03 
	[[NetWorkRequestApi sharedNetWorkRequestApi] SearchPartWork:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
			NSLog(@"%@", responseObject);
			switch ([[responseObject objectForKey:@"Tag"] integerValue]) {
				case 1:
				{
//					[[iToast makeText:[responseObject objectForKey:@"Message"]] show];
					self.mArrData2 = [responseObject objectForKey:@"PartInfo"];
					if ([self.mArrData2 count]<=0)
					{
						hub.detailsLabelText = kNRStr_DataIsNull;
						[hub hide:YES afterDelay:3];
						return ;
					}
					[hub hide:YES];
					[self.tvSpareParts_JiLuChaXun reloadData];
				}
					break;
				default:
					break;
			}
	} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

		hub.detailsLabelText = kNRStr_LoadDataFailure;
		[hub hide:YES afterDelay:3];
//		[[iToast makeText:kNRStr_LoadDataFailure] show];
	}];

}

- (void)QRAndSearchSelector:(UIButton *)sender
{
	[self.mViewInput resignFirstResponder];
	switch (sender.tag) {
		case kBaoGongDanViewControllerTag_QR:
		{
			QRCodeViewController *vc = [[QRCodeViewController alloc] initWithNibName:nil bundle:nil];
			vc.delegate = self;
			[self presentViewController:vc animated:YES completion:nil];
		}
			break;

		case kBaoGongDanViewControllerTag_Search:
		{
			switch (self.mBaoGongDanViewControllerType) {
				case kBaoGongDanViewControllerType_SpareParts:
				{
					switch (self.mBaoGongDanViewControllerTab) {
						case kBaoGongDanViewControllerTab_WanGongBaoGong:
						{
							if ([m_hv1_tfDingDanHao isEqualToString:@""]) {
								[[iToast makeText:@"请输入订单号"] show];

								return;
							}

							MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
							hub.detailsLabelText = kNRStr_LoadingData;
							NSDictionary *dictionary = @{
										@"AUFNR"	: m_hv1_tfDingDanHao,
										@"VORNR"	: @"0010"
										};

							[[NetWorkRequestApi sharedNetWorkRequestApi] GetPartInfo:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
								NSLog(@"%@", responseObject);
								switch ([[responseObject objectForKey:@"Tag"] integerValue]) {
									case 1:
									{
										m_hv1_bSearch = YES;
										[hub hide:YES];

										self.mArrData1 = responseObject;
										[self.tvSpareParts_WanGongBaoGong reloadData];
									}
										break;
									default:
										break;
								}
							} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
								
								[[iToast makeText:kNRStr_LoadDataFailure] show];
							}];
						}
							break;


						case kBaoGongDanViewControllerTab_JiLuChaXun:
						{

						}
							break;


						case kBaoGongDanViewControllerTab_TongBuSheZhi:
						{
							NSDictionary *dictionary = @{
														 @"ISSUCCESS"	: @"E",
														 @"EDATE"	: @"",
														 @"AUFNR"	: m_hv3_tfDingDanHao,
														 @"BDATE"	: @""
														 };

							MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
							hub.detailsLabelText = kNRStr_LoadingData;
							[[NetWorkRequestApi sharedNetWorkRequestApi] SearchPartWork:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
								NSLog(@"%@", responseObject);
								switch ([[responseObject objectForKey:@"Tag"] integerValue]) {
									case 1:
									{

										self.mArrData3 = [responseObject objectForKey:@"PartInfo"];

										if ([self.mArrData3 count]<=0) {
											hub.detailsLabelText = kNRStr_DataIsNull;
											return ;
										}
										[hub hide:YES];

										[self.tvSpareParts_TongBuSheZhi reloadData];
									}
										break;
									default:
										break;
								}
							} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

								[[iToast makeText:kNRStr_LoadDataFailure] show];
							}];

						}
							break;

						default:
							break;
					}
				}
					break;
				case kBaoGongDanViewControllerType_Merchandiser:
				{

					switch (self.mBaoGongDanViewControllerTab) {
						case kBaoGongDanViewControllerTab_WanGongBaoGong:
						{
							if ([m_hv4_tfDingDanHao isEqualToString:@""]) {
								[[iToast makeText:@"请输入订单号"] show];
								return;
							}


							MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
							hub.detailsLabelText = kNRStr_LoadingData;
							NSDictionary *dictionary = @{@"AUFNR" : m_hv4_tfDingDanHao,
														 @"VORNR"		: @"0010" };
							[[NetWorkRequestApi sharedNetWorkRequestApi] GetForkmanInfo:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
								NSLog(@"%@", responseObject);
								[hub hide:YES];
								m_hv4_bSearch = YES;
								if (![responseObject objectForKey:@"GERNR"] || [[responseObject objectForKey:@"GERNR"] isEqualToString:@""]) {
									UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"没有数据请确认订单号" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
									[alertView show];
								} else {

									self.mArrData4 = responseObject;
									self.mArrTemp = [NSMutableArray array];
									NSString *str = [self.mArrData4 objectForKey:@"GERNR"];
									NSRange range = [str rangeOfString:@"|" options:NSBackwardsSearch];

									if (range.length<=0) {

//										[self.mArrTemp addObject:str];
									}
									else
									{
										while (range.length>0)
										{
											NSString *str1 = [str substringWithRange:NSMakeRange(range.location + range.length, str.length- 1-range.location)];
											NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"0", @"check", str1, @"lb", nil];
											[self.mArrTemp addObject:dic];
											str = [str substringWithRange:NSMakeRange(0, range.location)];
											range = [str rangeOfString:@"|" options:NSBackwardsSearch];
									}

									[self.tvMerchandiser_WanGongBaoGong reloadData];
									}
								}


							} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
								[[iToast makeText:kNRStr_LoadDataFailure] show];
							}];
						}
							break;


						case kBaoGongDanViewControllerTab_JiLuChaXun:
						{

						}
							break;
							
							
						case kBaoGongDanViewControllerTab_TongBuSheZhi:
						{

							//							http://220.178.74.185:17777/hmp_002/api/SearchForkmanWork?Token=f2b6ea1ece0a47748fc00bd228b21b78   searchParas:{"ISSUCCESS":"E","EDATE":"","AUFNR":"","BDATE":""}
							NSDictionary *dictionary = @{
														 @"ISSUCCESS"	: @"E",
														 @"EDATE"	: @"",
														 @"AUFNR"	: m_hv6_tfDingDanHao,
														 @"BDATE"	: @""
														 };

							MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
							hub.detailsLabelText = kNRStr_LoadingData;
							[[NetWorkRequestApi sharedNetWorkRequestApi] SearchForkmanWork:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
								NSLog(@"%@", responseObject);
								switch ([[responseObject objectForKey:@"Tag"] integerValue]) {
									case 1:
									{
										self.mArrData6 = [responseObject objectForKey:@"Result"];
										if ([self.mArrData6 count]<=0) {
											hub.detailsLabelText = kNRStr_DataIsNull;
											return ;
										}
										[hub hide:YES];
										[self.tvMerchandiser_TongBuSheZhi reloadData];
									}
										break;
									default:
										break;
								}
							} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

								[[iToast makeText:kNRStr_LoadDataFailure] show];
							}];
							

						}
							break;
							
						default:
							break;
					}
				}
					break;
					
				default:
					break;
			}
		}
			break;

  default:
			break;
	}
}

#pragma mark 11 SpareParts WanGongBaoGong
- (BGDSparePartsWanGongBaoGongHeaderView *)cellWith_SpareParts_WanGongBaoGong:(UITableView *)tableView  viewForHeaderInSection:(NSInteger)section
{

	static NSString *strHeaderFooterViewIdentifier = @"BGDSparePartsWanGongBaoGongHeaderView";
	BGDSparePartsWanGongBaoGongHeaderView *cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:strHeaderFooterViewIdentifier];
	if (!cell)
	{
		NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"BGBHeaderFooterView" owner:self options:nil];
		for (id obj in array) {
			if ([obj isKindOfClass:[BGDSparePartsWanGongBaoGongHeaderView class]]) {
				cell = obj;
			}
		}
	}

	self.hv1 = cell;
	UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 30)];
	UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
	[btn1 setBackgroundImage:[UIImage imageNamed:@"ico_quickmark_simple"] forState:UIControlStateNormal];
	btn1.frame = CGRectMake(0, 0, 30, 30);
	btn1.tag = kBaoGongDanViewControllerTag_QR;
	[v addSubview:btn1];
	[btn1 addTarget:self action:@selector(QRAndSearchSelector:) forControlEvents:UIControlEventTouchUpInside];

	UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
	[btn2 setBackgroundImage:[UIImage imageNamed:@"ico_searchgrey"] forState:UIControlStateNormal];
	btn2.frame = CGRectMake(40, 0, 30, 30);
	btn2.tag = kBaoGongDanViewControllerTag_Search;
	[v addSubview:btn2];
	[btn2 addTarget:self action:@selector(QRAndSearchSelector:) forControlEvents:UIControlEventTouchUpInside];

	cell.tfDingDanHao.rightView = v;
	cell.tfDingDanHao.rightViewMode = UITextFieldViewModeAlways;

	UIButton *btnGongXuHao = [UIButton buttonWithType:UIButtonTypeCustom];
	[btnGongXuHao setBackgroundImage:[UIImage imageNamed:@"bg_down"] forState:UIControlStateNormal];
	btnGongXuHao.frame = CGRectMake(40, 0, 30, 30);
	cell.tfGongXuHao.rightView = btnGongXuHao;
	cell.tfGongXuHao.rightViewMode = UITextFieldViewModeAlways;

	UIButton *btnBaoGongRen = [UIButton buttonWithType:UIButtonTypeCustom];
	[btnBaoGongRen setBackgroundImage:[UIImage imageNamed:@"bg_down"] forState:UIControlStateNormal];
	btnBaoGongRen.frame = CGRectMake(40, 0, 30, 30);
	cell.tfBaoGongRen.rightView = btnBaoGongRen;
	cell.tfBaoGongRen.rightViewMode = UITextFieldViewModeAlways;

	[cell.btnTianjiaoBaoGong addTarget:self action:@selector(tijiaobaogong:) forControlEvents:UIControlEventTouchUpInside];
	cell.btnTianjiaoBaoGong.layer.cornerRadius = 5;
	cell.btnTianjiaoBaoGong.layer.borderColor = [UIColor lightGrayColor].CGColor;
	cell.btnTianjiaoBaoGong.layer.borderWidth = 1;

	cell.tfDingDanHao.delegate = self;
	cell.tfGongXuHao.delegate = self;
	cell.tfBaoGongRen.delegate = self;
	cell.tfBaoGongShu.delegate = self;

	cell.tfBaoGongRen.text = [[gUserInfo objectForKey:@"User"] objectForKey:@"UserName"];

	cell.tfDingDanHao.tag = kBaoGongDanViewControllerTag_tfDingDanHao;
	cell.tfGongXuHao.tag = kBaoGongDanViewControllerTag_tfGongXuHao;
	cell.tfBaoGongRen.tag = kBaoGongDanViewControllerTag_tfBaoGongRen;
	cell.tfBaoGongShu.tag = kBaoGongDanViewControllerTag_tfBaoGongShu;

	cell.lbYiBaoShu.text = self.mArrData1 ? @"" : [self.mArrData1 objectForKey:@"QTYED"];
	cell.lbYiBaoShu.textColor = [UIColor blackColor];
	cell.lbDingDanLiang.text = self.mArrData1 ? @"" : [self.mArrData1 objectForKey:@"QTY"];
	cell.lbDingDanLiang.textColor = [UIColor blackColor];

	NSString *str = [self.mArrData1 objectForKey:@"CENTER"];
	NSRange range = [str rangeOfString:@"->"];
	if (range.length<=0) {
		self.hv1.tfGongXuHao.text = str;
	}
	else
	{
		self.hv1.tfGongXuHao.text = [str substringToIndex:range.location];
	}
//	while (range.length>0) {
//		range = [str rangeOfString:@"->"];
//	}

	cell.tfDingDanHao.text = m_hv1_tfDingDanHao;

	return cell;
}

- (void)tijiaobaogong:(UIButton *)sender
{

	[self.mViewInput resignFirstResponder];
//#pragma mark SavePartWork
	//url:ht tp://220.178.74.185:17777/hmp_002/api/SavePartWork?Token=  center:0010  bg:10
	// us:zhangzenghui maH97Y5-22001  token:828c870b2f4d4fe5ad1dbe301d8683bf
	if ([self.hv1.tfDingDanHao.text isEqualToString:@""] || !self.hv1.tfDingDanHao.text) {
		UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"请输入订单号" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
		[alertView show];
		return;
	}

	if ([self.hv1.tfBaoGongShu.text isEqualToString:@""] || !self.hv1.tfBaoGongShu.text) {
		UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"请输入报工数" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
		[alertView show];
		return;
	}

	if ([self.hv1.tfBaoGongShu.text integerValue] + [self.hv1.lbYiBaoShu.text integerValue] > [self.hv1.lbDingDanLiang.text integerValue]) {
		UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"报工数和已报数之和不能大于订单量" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
		[alertView show];
		return;
	}

	if (!m_hv1_bSearch)
	{
		UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"请先查询，再提交" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
		[alertView show];
		return;
	}

	MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
	hub.detailsLabelText = kNRStr_LoadingData;
	NSRange range1 = [self.hv1.tfGongXuHao.text rangeOfString:@"("];
	NSRange range2 = [self.hv1.tfGongXuHao.text rangeOfString:@")"];
	NSString *str = [self.hv1.tfGongXuHao.text substringWithRange:NSMakeRange(range1.location+range1.length, range2.location-range1.location-range1.length)];
	NSDictionary *dictionary = @{@"center" : str,
								 @"bg"		: self.hv1.tfBaoGongShu.text,
								 @"us"		: [[gUserInfo objectForKey:@"User"] objectForKey:@"UserName"],
								 @"ma"		: [self.mArrData1 objectForKey:@"MATNR"]};
	[[NetWorkRequestApi sharedNetWorkRequestApi] SavePartWork:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
		NSLog(@"%@", responseObject);
		switch ([[responseObject objectForKey:@"Tag"] integerValue]) {
			case 1:
			{
				[hub hide:YES];
				UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:[responseObject objectForKey:@"Message"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
				[alertView show];
			}
				break;

			default:
				break;
		}
	} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

		[[iToast makeText:kNRStr_LoadDataFailure] show];
	}];
}

#pragma mark 12 SpareParts JiLuChaXun
- (BGDSparePartsJiLuChaXunHeaderView *)cellWith_SpareParts_JiLuChaXun:(UITableView *)tableView  viewForHeaderInSection:(NSInteger)section
{
	static NSString *strHeaderFooterViewIdentifier = @"BGDSparePartsJiLuChaXunHeaderView";
	BGDSparePartsJiLuChaXunHeaderView *cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:strHeaderFooterViewIdentifier];
	if (!cell)
	{
		for (id obj in [[NSBundle mainBundle] loadNibNamed:@"BGBHeaderFooterView" owner:self options:nil]) {
			if ([obj isKindOfClass:[BGDSparePartsJiLuChaXunHeaderView class]]) {
				cell = obj;
			}
		}
	}

	UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
	UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
	[btn1 setBackgroundImage:[UIImage imageNamed:@"ico_quickmark_simple"] forState:UIControlStateNormal];
	btn1.frame = CGRectMake(0, 0, 30, 30);
	btn1.tag = kBaoGongDanViewControllerTag_QR;
	[v addSubview:btn1];
	[btn1 addTarget:self action:@selector(QRAndSearchSelector:) forControlEvents:UIControlEventTouchUpInside];

//	UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
//	[btn2 setBackgroundImage:[UIImage imageNamed:@"ico_searchgrey"] forState:UIControlStateNormal];
//	btn2.frame = CGRectMake(40, 0, 30, 30);
//	btn2.tag = kBaoGongDanViewControllerTag_Search;
//	[v addSubview:btn2];

	UIButton *btnGongXuHao = [UIButton buttonWithType:UIButtonTypeCustom];
	[btnGongXuHao setBackgroundImage:[UIImage imageNamed:@"bg_down"] forState:UIControlStateNormal];
	btnGongXuHao.frame = CGRectMake(0, 0, 30, 30);
	cell.tfTianShu.rightView = btnGongXuHao;
	cell.tfTianShu.rightViewMode = UITextFieldViewModeAlways;

	UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
	[btn3 setBackgroundImage:[UIImage imageNamed:@"bg_down"] forState:UIControlStateNormal];
	btn3.frame = CGRectMake(0, 0, 30, 30);
	cell.tfZhuangTai.rightView = btn3;
	cell.tfZhuangTai.rightViewMode = UITextFieldViewModeAlways;

	cell.btnChaXun.layer.cornerRadius = 6;
	cell.btnChaXun.layer.borderColor = [UIColor lightGrayColor].CGColor;
	cell.btnChaXun.layer.borderWidth = 1;
	[cell.btnChaXun addTarget:self action:@selector(SearchSelector:) forControlEvents:UIControlEventTouchUpInside];

	cell.tfDingDanHao.rightView = v;
	cell.tfDingDanHao.rightViewMode = UITextFieldViewModeAlways;

	cell.tfDingDanHao.delegate = self;
	cell.tfTianShu.delegate = self;
	cell.tfTianShu.tag = 122;
	cell.tfZhuangTai.delegate = self;
	cell.tfZhuangTai.tag = 123;

	cell.tfDingDanHao.tag = 121;
	cell.tfDingDanHao.text = m_hv2_tfDingDanHao;
	cell.tfTianShu.text = m_hv2_tfTianShu;
	cell.tfZhuangTai.text = m_hv2_tfZhuangTai;

	self.hv2 = cell;
	return cell;
}

#pragma mark 13 SpareParts TongBuSheZhi
- (BGDSparePartsTongBuSheZhiHeaderView *)cellWith_SpareParts_TongBuSheZhi:(UITableView *)tableView  viewForHeaderInSection:(NSInteger)section
{
	static NSString *strHeaderFooterViewIdentifier = @"BGDSparePartsTongBuSheZhiHeaderView";
	BGDSparePartsTongBuSheZhiHeaderView *cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:strHeaderFooterViewIdentifier];
	if (!cell)
	{
		for (id obj in [[NSBundle mainBundle] loadNibNamed:@"BGBHeaderFooterView" owner:self options:nil]) {
			if ([obj isKindOfClass:[BGDSparePartsTongBuSheZhiHeaderView class]]) {
				cell = obj;
			}
		}
	}
	UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 30)];
	UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
	[btn1 setBackgroundImage:[UIImage imageNamed:@"ico_quickmark_simple"] forState:UIControlStateNormal];
	btn1.frame = CGRectMake(0, 0, 30, 30);
	btn1.tag = kBaoGongDanViewControllerTag_QR;
	[v addSubview:btn1];
	[btn1 addTarget:self action:@selector(QRAndSearchSelector:) forControlEvents:UIControlEventTouchUpInside];

	UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
	[btn2 setBackgroundImage:[UIImage imageNamed:@"ico_searchgrey"] forState:UIControlStateNormal];
	btn2.frame = CGRectMake(40, 0, 30, 30);
	btn2.tag = kBaoGongDanViewControllerTag_Search;
	[v addSubview:btn2];
	[btn2 addTarget:self action:@selector(QRAndSearchSelector:) forControlEvents:UIControlEventTouchUpInside];

	cell.tfDingDanHao.rightView = v;
	cell.tfDingDanHao.rightViewMode = UITextFieldViewModeAlways;

	cell.tfDingDanHao.delegate = self;

	cell.tfDingDanHao.tag = 131;
	cell.tfDingDanHao.text = m_hv3_tfDingDanHao;

	self.hv3 = cell;

	return cell;

}

#pragma mark 21 Merchandiser WanGongBaoGong
- (BGDMerchandiserWanGongBaoGongHeaderView *)cellWith_Merchandiser_WanGongBaoGong:(UITableView *)tableView  viewForHeaderInSection:(NSInteger)section
{
	static NSString *strHeaderFooterViewIdentifier = @"BGDMerchandiserWanGongBaoGongHeaderView";
	BGDMerchandiserWanGongBaoGongHeaderView *cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:strHeaderFooterViewIdentifier];
	if (!cell)
	{
		for (id obj in [[NSBundle mainBundle] loadNibNamed:@"BGBHeaderFooterView" owner:self options:nil]) {
			if ([obj isKindOfClass:[BGDMerchandiserWanGongBaoGongHeaderView class]]) {
				cell = obj;
			}
		}
	}

	UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 30)];
	UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
	[btn1 setBackgroundImage:[UIImage imageNamed:@"ico_quickmark_simple"] forState:UIControlStateNormal];
	btn1.frame = CGRectMake(0, 0, 30, 30);
	btn1.tag = kBaoGongDanViewControllerTag_QR;
	[v addSubview:btn1];
	[btn1 addTarget:self action:@selector(QRAndSearchSelector:) forControlEvents:UIControlEventTouchUpInside];

	UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
	[btn2 setBackgroundImage:[UIImage imageNamed:@"ico_searchgrey"] forState:UIControlStateNormal];
	btn2.frame = CGRectMake(40, 0, 30, 30);
	btn2.tag = kBaoGongDanViewControllerTag_Search;
	[v addSubview:btn2];
	[btn2 addTarget:self action:@selector(QRAndSearchSelector:) forControlEvents:UIControlEventTouchUpInside];

	UIButton *btnGongXuHao = [UIButton buttonWithType:UIButtonTypeCustom];
	[btnGongXuHao setBackgroundImage:[UIImage imageNamed:@"bg_down"] forState:UIControlStateNormal];
	btnGongXuHao.frame = CGRectMake(40, 0, 30, 30);
	cell.tfGongXuHao.rightView = btnGongXuHao;
	cell.tfGongXuHao.rightViewMode = UITextFieldViewModeAlways;

	UIButton *btnBaoGongRen = [UIButton buttonWithType:UIButtonTypeCustom];
	[btnBaoGongRen setBackgroundImage:[UIImage imageNamed:@"bg_down"] forState:UIControlStateNormal];
	btnBaoGongRen.frame = CGRectMake(40, 0, 30, 30);
	cell.tfBaoGongRen.rightView = btnBaoGongRen;
	cell.tfBaoGongRen.rightViewMode = UITextFieldViewModeAlways;

	cell.tfDingDanHao.rightView = v;
	cell.tfDingDanHao.rightViewMode = UITextFieldViewModeAlways;

	cell.tfDingDanHao.delegate = self;
	cell.tfGongXuHao.delegate = self;
	cell.tfBaoGongRen.delegate = self;

	cell.tfBaoGongRen.tag = 213;
	cell.tfGongXuHao.tag = 212;

	self.hv4 = cell;

	cell.lbHeTongHao.text = [self.mArrData4 objectForKey:@"CONTRACTNO"];
	cell.lbKeHuHao.text = [self.mArrData4 objectForKey:@"CUSTNAME"];
	cell.lbDingDanShuLiang.text = [self.mArrData4 objectForKey:@"ORDERCOUNT"];
	cell.tfBaoGongRen.text = [[gUserInfo objectForKey:@"User"] objectForKey:@"UserName"];

	NSString *str = [self.mArrData4 objectForKey:@"ARBPL"];
	NSRange range = [str rangeOfString:@"->"];
	if (range.length<=0) {
		self.hv4.tfGongXuHao.text = str;
	}
	else
	{
		self.hv4.tfGongXuHao.text = [str substringToIndex:range.location];
	}

	cell.tfDingDanHao.tag = 211;
	cell.tfDingDanHao.text = m_hv4_tfDingDanHao;

	return cell;

}

#pragma mark 22 Merchandiser JiLuChaXun
- (BGDMerchandiserJiLuChaXunHeaderView *)cellWith_Merchandiser_JiLuChaXun:(UITableView *)tableView  viewForHeaderInSection:(NSInteger)section
{
	static NSString *strHeaderFooterViewIdentifier = @"BGDMerchandiserJiLuChaXunHeaderView";
	BGDMerchandiserJiLuChaXunHeaderView *cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:strHeaderFooterViewIdentifier];
	if (!cell)
	{
		for (id obj in [[NSBundle mainBundle] loadNibNamed:@"BGBHeaderFooterView" owner:self options:nil]) {
			if ([obj isKindOfClass:[BGDMerchandiserJiLuChaXunHeaderView class]]) {
				cell = obj;
			}
		}
	}

	UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
	UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
	[btn1 setBackgroundImage:[UIImage imageNamed:@"ico_quickmark_simple"] forState:UIControlStateNormal];
	btn1.frame = CGRectMake(0, 0, 30, 30);
	btn1.tag = kBaoGongDanViewControllerTag_QR;
	[v addSubview:btn1];
	[btn1 addTarget:self action:@selector(QRAndSearchSelector:) forControlEvents:UIControlEventTouchUpInside];

//	UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
//	[btn2 setBackgroundImage:[UIImage imageNamed:@"ico_searchgrey"] forState:UIControlStateNormal];
//	btn2.frame = CGRectMake(40, 0, 30, 30);
//	btn2.tag = kBaoGongDanViewControllerTag_Search;
//	[v addSubview:btn2];

	cell.tfDingDanHao.rightView = v;
	cell.tfDingDanHao.rightViewMode = UITextFieldViewModeAlways;


	cell.tfDingDanHao.delegate = self;
	cell.tfTianShu.delegate = self;
	cell.tfZhuangTai.delegate = self;

	UIButton *btnGongXuHao = [UIButton buttonWithType:UIButtonTypeCustom];
	[btnGongXuHao setBackgroundImage:[UIImage imageNamed:@"bg_down"] forState:UIControlStateNormal];
	btnGongXuHao.frame = CGRectMake(0, 0, 30, 30);
	cell.tfTianShu.rightView = btnGongXuHao;
	cell.tfTianShu.rightViewMode = UITextFieldViewModeAlways;

	UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
	[btn3 setBackgroundImage:[UIImage imageNamed:@"bg_down"] forState:UIControlStateNormal];
	btn3.frame = CGRectMake(0, 0, 30, 30);
	cell.tfZhuangTai.rightView = btn3;
	cell.tfZhuangTai.rightViewMode = UITextFieldViewModeAlways;

	cell.btnChaXun.layer.cornerRadius = 6;
	cell.btnChaXun.layer.borderColor = [UIColor lightGrayColor].CGColor;
	cell.btnChaXun.layer.borderWidth = 1;
	[cell.btnChaXun addTarget:self action:@selector(SearchSelector_22:) forControlEvents:UIControlEventTouchUpInside];

	cell.tfDingDanHao.rightView = v;
	cell.tfDingDanHao.rightViewMode = UITextFieldViewModeAlways;

	cell.tfDingDanHao.delegate = self;
	cell.tfTianShu.delegate = self;
	cell.tfTianShu.tag = 222;
	cell.tfZhuangTai.delegate = self;
	cell.tfZhuangTai.tag = 223;

	cell.tfDingDanHao.tag = 221;
	cell.tfDingDanHao.text = m_hv5_tfDingDanHao;
	cell.tfTianShu.text = m_hv5_tfTianShu;
	cell.tfZhuangTai.text = m_hv5_tfZhuangTai;

	self.hv5 = cell;

	return cell;
}

- (void)SearchSelector_22:(UIButton *)sender
{
	[self.mViewInput resignFirstResponder];
	NSString *order=m_hv5_tfDingDanHao;
	NSString *end = nil;
	NSString *day = self.hv5.tfTianShu.text;
	NSString *star = [[NSDate date] dateWithNOTimeString];
	NSString *status = @"E";

	//searchRecord url:http://220.178.74.185:17777/hmp_002/api/SearchPartWork?Token=80fe649391924eada276117f1302ed8e  order:  day:当天  status:  star:2014-12-02   end:2014-12-02
	//searchRecord url:http://220.178.74.185:17777/hmp_002/api/SearchPartWork?Token=80fe649391924eada276117f1302ed8e  order:  day:当天  status:E  star:2014-12-02   end:2014-12-02

	NSDictionary *dictionary = nil;
	if ([self.hv5.tfTianShu.text isEqualToString: @"当天"]) {
		end =[[NSDate date] dateWithNOTimeString];
	}
	else if ([self.hv5.tfTianShu.text isEqualToString: @"三天"]) {
		end=[[NSDate dateWithTimeInterval:-3*24*60*60 sinceDate:[NSDate date]] dateWithNOTimeString];
	}
	else if ([self.hv5.tfTianShu.text isEqualToString: @"一周"]) {
		end=[[NSDate dateWithTimeInterval:-7*24*60*60 sinceDate:[NSDate date]] dateWithNOTimeString];
	}
	else
	{
		end = @"";
	}
	day = self.hv5.tfTianShu.text;

	if ([self.hv5.tfZhuangTai.text isEqualToString: @"已同步"]) {
		status = @"S";
	}
	else if ([self.hv5.tfZhuangTai.text isEqualToString: @"待同步"]) {
		status = @"E";
	}
	else if ([self.hv5.tfZhuangTai.text isEqualToString: @"已取消"]) {
		status = @"X";
	} else {
		status = @"";
	}
	dictionary = @{
				   @"AUFNR"	: order,
				   @"EDATE"	: end,
				   @"BDATE"	: star,
				   @"ISSUCCESS" : status
				   };

	MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
	hub.detailsLabelText = kNRStr_LoadingData;
	[[NetWorkRequestApi sharedNetWorkRequestApi] SearchForkmanWork:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
		NSLog(@"%@", responseObject);
		switch ([[responseObject objectForKey:@"Tag"] integerValue]) {
			case 1:
			{
				self.mArrData5 = [responseObject objectForKey:@"Result"];
				if ([self.mArrData5 count]<=0) {
					hub.detailsLabelText = kNRStr_DataIsNull;
					[hub hide:YES afterDelay:3];
					return ;
				}
				[hub hide:YES];
				[self.tvMerchandiser_JiLuChaXun reloadData];
			}
				break;
			default:
				break;
		}
	} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

		[[iToast makeText:kNRStr_LoadDataFailure] show];
	}];

}

#pragma mark 23 Merchandiser TongBuSheZhi
- (BGDMerchandiserTongBuSheZhiHeaderView *)cellWith_Merchandiser_TongBuSheZhi:(UITableView *)tableView  viewForHeaderInSection:(NSInteger)section
{
	static NSString *strHeaderFooterViewIdentifier = @"BGDMerchandiserTongBuSheZhiHeaderView";
	BGDMerchandiserTongBuSheZhiHeaderView *cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:strHeaderFooterViewIdentifier];
	if (!cell)
	{
		for (id obj in [[NSBundle mainBundle] loadNibNamed:@"BGBHeaderFooterView" owner:self options:nil]) {
			if ([obj isKindOfClass:[BGDMerchandiserTongBuSheZhiHeaderView class]]) {
				cell = obj;
			}
		}
	}

	UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 70, 30)];
	UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
	[btn1 setBackgroundImage:[UIImage imageNamed:@"ico_quickmark_simple"] forState:UIControlStateNormal];
	btn1.frame = CGRectMake(0, 0, 30, 30);
	btn1.tag = kBaoGongDanViewControllerTag_QR;
	[v addSubview:btn1];
	[btn1 addTarget:self action:@selector(QRAndSearchSelector:) forControlEvents:UIControlEventTouchUpInside];

	UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
	[btn2 setBackgroundImage:[UIImage imageNamed:@"ico_searchgrey"] forState:UIControlStateNormal];
	btn2.frame = CGRectMake(40, 0, 30, 30);
	btn2.tag = kBaoGongDanViewControllerTag_Search;
	[v addSubview:btn2];
	[btn2 addTarget:self action:@selector(QRAndSearchSelector:) forControlEvents:UIControlEventTouchUpInside];

	cell.tfDingDanHao.rightView = v;
	cell.tfDingDanHao.rightViewMode = UITextFieldViewModeAlways;

	cell.tfDingDanHao.delegate = self;
	cell.tfDingDanHao.tag = 231;
	cell.tfDingDanHao.text = m_hv6_tfDingDanHao;

	self.hv6 = cell;

	return cell;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
	if (self.tvSpareParts_WanGongBaoGong == tableView)
	{
		return [self cellWith_SpareParts_WanGongBaoGong:tableView viewForHeaderInSection:section];
	}
	else if (self.tvSpareParts_JiLuChaXun == tableView)
	{
		return [self cellWith_SpareParts_JiLuChaXun:tableView viewForHeaderInSection:section];
	}
	else if (self.tvSpareParts_TongBuSheZhi == tableView)
	{
		return [self cellWith_SpareParts_TongBuSheZhi:tableView viewForHeaderInSection:section];
	}
	else if (self.tvMerchandiser_WanGongBaoGong == tableView)
	{
		return [self cellWith_Merchandiser_WanGongBaoGong:tableView viewForHeaderInSection:section];
	}
	else if (self.tvMerchandiser_JiLuChaXun == tableView)
	{
		return [self cellWith_Merchandiser_JiLuChaXun:tableView viewForHeaderInSection:section];
	}
	else if (self.tvMerchandiser_TongBuSheZhi == tableView)
	{
		return [self cellWith_Merchandiser_TongBuSheZhi:tableView viewForHeaderInSection:section];
	}
	else
	{
		return nil;
	}
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

	if (self.tvSpareParts_WanGongBaoGong == tableView)
	{
		static NSString *strCellIdentifier = @"BGDSparePartsWanGongBaoGongCell";
		UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strCellIdentifier];
		if (!cell)
		{
			cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:strCellIdentifier];
			//						cell = [[[NSBundle mainBundle] loadNibNamed:@"BaoGongDanTableViewCell" owner:self options:nil] objectAtIndex:0];
			//						cell.selectionStyle = UITableViewCellSelectionStyleNone;
		}

		switch (indexPath.row)
		{
			case 0:
			{
				cell.textLabel.text = @"物料号";
				cell.detailTextLabel.text = [self.mArrData1 objectForKey:@"MATNR"];
			}
				break;

			case 1:
			{
				cell.textLabel.text = @"物料描述";
				cell.detailTextLabel.text = [self.mArrData1 objectForKey:@"MAKTX"];
			}
				break;

			case 2:
			{
				cell.textLabel.text = @"工艺路线";
				cell.detailTextLabel.text = [self.mArrData1 objectForKey:@"S_ROUTING"];
			}
				break;

			default:
			{
			}
				break;

		}
		cell.textLabel.font = [UIFont systemFontOfSize:15];
		cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
		return cell;
	}
	else if (self.tvSpareParts_JiLuChaXun == tableView)
	{
		static NSString *strCellIdentifier = @"BGDSparePartsJiLuChaXunCell";
		BGDSparePartsJiLuChaXunCell *cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:strCellIdentifier];
		if (!cell)
		{
			//						cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:strCellIdentifier];
			for (id obj in [[NSBundle mainBundle] loadNibNamed:@"BaoGongDanTableViewCell" owner:self options:nil]) {
				if ([obj isKindOfClass:[BGDSparePartsJiLuChaXunCell class]]) {
					cell = obj;
				}
			}
			cell.selectionStyle = UITableViewCellSelectionStyleNone;
		}

		cell.lbDingDanHao.text = [[self.mArrData2 objectAtIndex:indexPath.row] objectForKey:@"AUFNR"];
		cell.lbGongXu.text = [[self.mArrData2 objectAtIndex:indexPath.row] objectForKey:@"VORNR"];
		cell.lbShuLiang.text = [[self.mArrData2 objectAtIndex:indexPath.row] objectForKey:@"LMNGA"];
		cell.lbZhuangTai.text = [[self.mArrData2 objectAtIndex:indexPath.row] objectForKey:@"ISSUCCESS"];

		cell.textLabel.font = [UIFont systemFontOfSize:15];
		cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
		return cell;
	}
	else if (self.tvSpareParts_TongBuSheZhi == tableView)
	{
		static NSString *strCellIdentifier = @"BGDSparePartsTongBuSheZhiCell";
		BGDSparePartsTongBuSheZhiCell *cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:strCellIdentifier];
		if (!cell)
		{
			//						cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:strCellIdentifier];
			for (id obj in [[NSBundle mainBundle] loadNibNamed:@"BaoGongDanTableViewCell" owner:self options:nil]) {
				if ([obj isKindOfClass:[BGDSparePartsTongBuSheZhiCell class]]) {
					cell = obj;
				}
			}
			cell.selectionStyle = UITableViewCellSelectionStyleNone;
		}

		cell.btnCheck.tag = indexPath.row;
		if (cell.btnCheck.bCheck) {
			[cell.btnCheck setImage:[UIImage imageNamed:@"check"] forState:UIControlStateNormal];
		} else {
			[cell.btnCheck setImage:[UIImage imageNamed:@"uncheck"] forState:UIControlStateNormal];
		}
		[cell.btnCheck addTarget:self action:@selector(btnCheckSelector_3:) forControlEvents:UIControlEventTouchUpInside];
		cell.lbDingDanHao.text = [[self.mArrData3 objectAtIndex:indexPath.row] objectForKey:@"AUFNR"];
		cell.lbGongXu.text = [[self.mArrData3 objectAtIndex:indexPath.row] objectForKey:@"VORNR"];
		cell.lbShuLiang.text = [[self.mArrData3 objectAtIndex:indexPath.row] objectForKey:@"LMNGA"];
		cell.lbZhuangTai.text = [[self.mArrData3 objectAtIndex:indexPath.row] objectForKey:@"ISSUCCESS"];

		cell.textLabel.font = [UIFont systemFontOfSize:15];
		cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
		return cell;

	}
	else if (self.tvMerchandiser_WanGongBaoGong == tableView)
	{
		static NSString *strCellIdentifier = @"BGDMerchandiserWanGongBaoGongCell";
		BGDMerchandiserWanGongBaoGongCell *cell = [tableView dequeueReusableCellWithIdentifier:strCellIdentifier];
		if (!cell)
		{
			for (id obj in [[NSBundle mainBundle] loadNibNamed:@"BaoGongDanTableViewCell" owner:self options:nil]) {
				if ([obj isKindOfClass:[BGDMerchandiserWanGongBaoGongCell class]]) {
					cell = obj;
				}
			}
			
			cell.selectionStyle = UITableViewCellSelectionStyleNone;
		}


		if ([[[self.mArrTemp objectAtIndex:indexPath.row] objectForKey:@"check"] boolValue]) {
			[cell.btnCheck setImage:[UIImage imageNamed:@"check"] forState:UIControlStateNormal];
		} else {
			[cell.btnCheck setImage:[UIImage imageNamed:@"uncheck"] forState:UIControlStateNormal];
		}
		cell.btnCheck.tag = indexPath.row;
		[cell.btnCheck addTarget:self action:@selector(btnCheckSelector_4:) forControlEvents:UIControlEventTouchUpInside];

		cell.lbDingDanHao.text = [[self.mArrTemp objectAtIndex:indexPath.row] objectForKey:@"lb"];
		cell.textLabel.font = [UIFont systemFontOfSize:15];
		cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
		return cell;
	}
	else if (self.tvMerchandiser_JiLuChaXun == tableView)
	{
		static NSString *strCellIdentifier = @"BGDMerchandiserJiLuChaXunCell";
		BGDMerchandiserJiLuChaXunCell *cell = [tableView dequeueReusableCellWithIdentifier:strCellIdentifier];
		if (!cell)
		{
			for (id obj in [[NSBundle mainBundle] loadNibNamed:@"BaoGongDanTableViewCell" owner:self options:nil]) {
				if ([obj isKindOfClass:[BGDMerchandiserJiLuChaXunCell class]]) {
					cell = obj;
				}
			}

		}

		cell.lbDingDanHao.text = [[self.mArrData5 objectAtIndex:indexPath.row] objectForKey:@"AUFNR"];
		cell.lbGongXu.text = [[self.mArrData5 objectAtIndex:indexPath.row] objectForKey:@"VORNR"];
		cell.lbShuLiang.text = [[self.mArrData5 objectAtIndex:indexPath.row] objectForKey:@"LMNGA"];
		cell.lbZhuangTai.text = [[self.mArrData5 objectAtIndex:indexPath.row] objectForKey:@"ISSUCCESS"];

		cell.textLabel.font = [UIFont systemFontOfSize:15];
		cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
		return cell;
	}
	else if (self.tvMerchandiser_TongBuSheZhi == tableView)
	{
		static NSString *strCellIdentifier = @"BGDMerchandiserTongBuSheZhiCell";
		BGDMerchandiserTongBuSheZhiCell *cell = [tableView dequeueReusableCellWithIdentifier:strCellIdentifier];
		if (!cell)
		{
			for (id obj in [[NSBundle mainBundle] loadNibNamed:@"BaoGongDanTableViewCell" owner:self options:nil])
			{
				if ([obj isKindOfClass:[BGDMerchandiserTongBuSheZhiCell class]]) {
					cell = obj;
				}
			}
		}

		cell.btnCheck.tag = indexPath.row;
		if (cell.btnCheck.bCheck) {
			[cell.btnCheck setImage:[UIImage imageNamed:@"check"] forState:UIControlStateNormal];
		} else {
			[cell.btnCheck setImage:[UIImage imageNamed:@"uncheck"] forState:UIControlStateNormal];
		}
		[cell.btnCheck addTarget:self action:@selector(btnCheckSelector_6:) forControlEvents:UIControlEventTouchUpInside];
		cell.lbDingDanHao.text = [[self.mArrData6 objectAtIndex:indexPath.row] objectForKey:@"AUFNR"];
		cell.lbGongXu.text = [[self.mArrData6 objectAtIndex:indexPath.row] objectForKey:@"VORNR"];
		cell.lbShuLiang.text = [[self.mArrData6 objectAtIndex:indexPath.row] objectForKey:@"LMNGA"];
		cell.lbZhuangTai.text = [[self.mArrData6 objectAtIndex:indexPath.row] objectForKey:@"ISSUCCESS"];

		cell.textLabel.font = [UIFont systemFontOfSize:15];
		cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
		return cell;
	}
	else if (tableView == self.table)
	{
		static NSString *strIdentifier = @"strIdentifier";
		UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strIdentifier];
		if (!cell) {
			cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:strIdentifier];
		}
		cell.textLabel.text = [self.mArrTemp objectAtIndex:indexPath.row];

		return cell;
	}
	else
	{
		return 0;
	}
}

- (void)btnCheckSelector_3:(CheckBox *)sender
{
	[self.mViewInput resignFirstResponder];
	if (sender.bCheck) {
		sender.bCheck = NO;
		[m_hv3_guid removeObjectAtIndex:sender.tag];
		[sender setImage:[UIImage imageNamed:@"uncheck"] forState:UIControlStateNormal];
	} else {
		sender.bCheck = YES;
		[m_hv3_guid addObject:[self.mArrData3 objectAtIndex:sender.tag]];
		[sender setImage:[UIImage imageNamed:@"check"] forState:UIControlStateNormal];
	}
}


- (void)btnCheckSelector_4:(CheckBox *)sender
{
	[self.mViewInput resignFirstResponder];
	if (sender.bCheck) {
		sender.bCheck = NO;
		[sender setImage:[UIImage imageNamed:@"uncheck"] forState:UIControlStateNormal];
		[[self.mArrTemp objectAtIndex:sender.tag] setValue:@"0" forKey:@"check"];
	} else {
		sender.bCheck = YES;
		[sender setImage:[UIImage imageNamed:@"check"] forState:UIControlStateNormal];
		[[self.mArrTemp objectAtIndex:sender.tag] setValue:@"1" forKey:@"check"];
	}
}


- (void)btnCheckSelector_6:(CheckBox *)sender
{
	[self.mViewInput resignFirstResponder];
	if (sender.bCheck) {
		sender.bCheck = NO;
		[m_hv6_guid removeObjectAtIndex:sender.tag];
		[sender setImage:[UIImage imageNamed:@"uncheck"] forState:UIControlStateNormal];
	} else {
		sender.bCheck = YES;
		[m_hv6_guid addObject:[self.mArrData6 objectAtIndex:sender.tag]];
		[sender setImage:[UIImage imageNamed:@"check"] forState:UIControlStateNormal];
	}
}

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
	// Return NO if you do not want the specified item to be editable.
	return YES;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
	if (self.table == tableView) {
		switch (self.mBaoGongDanViewControllerType) {
			case kBaoGongDanViewControllerType_SpareParts:
			{
				switch (self.mBaoGongDanViewControllerTab) {
					case kBaoGongDanViewControllerTab_WanGongBaoGong:
					{
						self.vPop.hidden = YES;
						self.hv1.tfGongXuHao.text = [self.mArrTemp objectAtIndex:indexPath.row];
					}
						break;
						default:
					{

					}
						break;
				}
			}
				break;
			case kBaoGongDanViewControllerType_Merchandiser:
			{

				switch (self.mBaoGongDanViewControllerTab) {
					case kBaoGongDanViewControllerTab_WanGongBaoGong:
					{

						self.vPop.hidden = YES;
						self.hv4.tfGongXuHao.text = [[self.mArrTemp objectAtIndex:indexPath.row] objectForKey:@"lb"];

						NSRange range1 = [self.hv4.tfGongXuHao.text rangeOfString:@"("];
						NSRange range2 = [self.hv4.tfGongXuHao.text rangeOfString:@")"];
						NSString *gx = [self.hv4.tfGongXuHao.text substringWithRange:NSMakeRange(range1.location, range2.location-range1.location)];
						MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
						hub.detailsLabelText = kNRStr_LoadingData;
						NSDictionary *dictionary = @{@"AUFNR" : m_hv4_tfDingDanHao,
													 @"VORNR"		: gx };
						[[NetWorkRequestApi sharedNetWorkRequestApi] GetForkmanInfo:dictionary success:^(AFHTTPRequestOperation *operation, id responseObject) {
							NSLog(@"%@", responseObject);
							[hub hide:YES];
							if (![responseObject objectForKey:@"GERNR"] || [[responseObject objectForKey:@"GERNR"] isEqualToString:@""]) {
								UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"没有数据请确认订单号" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
								[alertView show];
							} else {

								self.mArrData4 = responseObject;
								self.mArrTemp = [NSMutableArray array];
								NSString *str = [self.mArrData4 objectForKey:@"GERNR"];
								NSRange range = [str rangeOfString:@"|" options:NSBackwardsSearch];

								if (range.length<=0) {

									//										[self.mArrTemp addObject:str];
								}
								else
								{
									while (range.length>0)
									{
										NSString *str1 = [str substringWithRange:NSMakeRange(range.location + range.length, str.length- 1-range.location)];
										NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"0", @"check", str1, @"lb", nil];
										[self.mArrTemp addObject:dic];
										str = [str substringWithRange:NSMakeRange(0, range.location)];
										range = [str rangeOfString:@"|" options:NSBackwardsSearch];
									}

									[self.tvMerchandiser_WanGongBaoGong reloadData];
								}
							}


						} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
							[[iToast makeText:kNRStr_LoadDataFailure] show];
						}];

					}
						break;
					default:
					{

					}
						break;
						
				}
			}
				break;
		default:
			{

			}
				break;
			}

		return;
	}
	switch (self.mBaoGongDanViewControllerType) {
		case kBaoGongDanViewControllerType_SpareParts:
		{
			switch (self.mBaoGongDanViewControllerTab) {
				case kBaoGongDanViewControllerTab_WanGongBaoGong:
				{
				}
					break;


				case kBaoGongDanViewControllerTab_JiLuChaXun:
				{

					[tableView deselectRowAtIndexPath:indexPath animated:YES];
					NSString *title = nil;
					NSString *message = [NSString stringWithFormat:@"报工人：%@\r\n报工日期：%@\r\n报工时间：%@\r\n其他信息：\r\n	%@", [[self.mArrData2 objectAtIndex:indexPath.row] objectForKey:@"REALNAME"], [[self.mArrData2 objectAtIndex:indexPath.row] objectForKey:@"TRANSDATE"], [[self.mArrData2 objectAtIndex:indexPath.row] objectForKey:@"TRANSTIME"], [[self.mArrData2 objectAtIndex:indexPath.row] objectForKey:@"MAKTX"]];

					AHAlertView *alert = [[AHAlertView alloc] initWithTitle:title message:message];
					[alert setCancelButtonTitle:@"取消" block:nil];
					[alert addButtonWithTitle:@"确定" block:^{}];
					[alert show];
				}
					break;


				case kBaoGongDanViewControllerTab_TongBuSheZhi:
				{
					[tableView deselectRowAtIndexPath:indexPath animated:YES];
					NSString *title = nil;
					NSString *message = [NSString stringWithFormat:@"报工人：%@\r\n报工日期：%@\r\n报工时间：%@\r\n其他信息：\r\n	%@",
										 [[self.mArrData3 objectAtIndex:indexPath.row] objectForKey:@"REALNAME"], [[self.mArrData3 objectAtIndex:indexPath.row] objectForKey:@"TRANSDATE"], [[self.mArrData3 objectAtIndex:indexPath.row] objectForKey:@"TRANSTIME"], [[self.mArrData3 objectAtIndex:indexPath.row] objectForKey:@"MAKTX"]];

					AHAlertView *alert = [[AHAlertView alloc] initWithTitle:title message:message];
					[alert setCancelButtonTitle:@"取消" block:nil];
					[alert addButtonWithTitle:@"确定" block:^{}];
					[alert show];
				}
					break;

				default:
					break;
			}
		}
			break;
		case kBaoGongDanViewControllerType_Merchandiser:
		{

			switch (self.mBaoGongDanViewControllerTab) {
				case kBaoGongDanViewControllerTab_WanGongBaoGong:
				{

					[tableView deselectRowAtIndexPath:indexPath animated:YES];
					NSString *title = nil;
					NSString *message = [NSString stringWithFormat:@"序列号：%@\r\n物料号：%@\r\n门架：%@\r\n阀门：\r\n%@完工数：\r\n%@", [[self.mArrTemp objectAtIndex:indexPath.row] objectForKey:@"lb"], [self.mArrData4 objectForKey:@"MATNR"], [self.mArrData4 objectForKey:@"MJHEIGHT"], [self.mArrData4 objectForKey:@"FPCOUNT"], [self.mArrData4 objectForKey:@"QTYED"]];

					AHAlertView *alert = [[AHAlertView alloc] initWithTitle:title message:message];
					[alert setCancelButtonTitle:@"取消" block:nil];
					[alert addButtonWithTitle:@"确定" block:^{}];
					[alert show];
				}
					break;


				case kBaoGongDanViewControllerTab_JiLuChaXun:
				{

					[tableView deselectRowAtIndexPath:indexPath animated:YES];
					NSString *title = nil;
					NSString *message = [NSString stringWithFormat:@"报工人：%@\r\n报工日期：%@\r\n报工时间：%@\r\n其他信息：\r\n	%@", [[self.mArrData5 objectAtIndex:indexPath.row] objectForKey:@"REALNAME"], [[self.mArrData5 objectAtIndex:indexPath.row] objectForKey:@"TRANSDATE"], [[self.mArrData5 objectAtIndex:indexPath.row] objectForKey:@"TRANSTIME"], [[self.mArrData5 objectAtIndex:indexPath.row] objectForKey:@"MAKTX"]];

					AHAlertView *alert = [[AHAlertView alloc] initWithTitle:title message:message];
					[alert setCancelButtonTitle:@"取消" block:nil];
					[alert addButtonWithTitle:@"确定" block:^{}];
					[alert show];
				}
					break;


				case kBaoGongDanViewControllerTab_TongBuSheZhi:
				{

					[tableView deselectRowAtIndexPath:indexPath animated:YES];
					NSString *title = nil;
					NSString *message = [NSString stringWithFormat:@"报工人：%@\r\n报工日期：%@\r\n报工时间：%@\r\n其他信息：\r\n	%@", [[self.mArrData6 objectAtIndex:indexPath.row] objectForKey:@"REALNAME"], [[self.mArrData6 objectAtIndex:indexPath.row] objectForKey:@"TRANSDATE"], [[self.mArrData6 objectAtIndex:indexPath.row] objectForKey:@"TRANSTIME"], [[self.mArrData6 objectAtIndex:indexPath.row] objectForKey:@"MAKTX"]];

					AHAlertView *alert = [[AHAlertView alloc] initWithTitle:title message:message];
					[alert setCancelButtonTitle:@"取消" block:nil];
					[alert addButtonWithTitle:@"确定" block:^{}];

					[alert show];
				}
					break;

				default:
					break;
			}
		}
			break;

		default:
			break;
	}
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
	[self.mViewInput resignFirstResponder];
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
	switch (textField.tag) {
	  case kBaoGongDanViewControllerTag_tfBaoGongRen:

			[self.mViewInput resignFirstResponder];
			return NO;
			break;

	case kBaoGongDanViewControllerTag_tfGongXuHao:
		{
			[self.mViewInput resignFirstResponder];
			if (![self.mArrData1 objectForKey:@"CENTER"]) {
				return NO;
			}
			self.mArrTemp = [NSMutableArray array];
			NSString *str = [self.mArrData1 objectForKey:@"CENTER"];
			NSRange range = [str rangeOfString:@"->"];

			if (range.length<=0) {

				[self.mArrTemp addObject:str];
			}
			else
			{
				while (range.length>0)
				{
					[self.mArrTemp addObject:[str substringToIndex:range.location]];


						str = [str substringFromIndex:range.length + range.location];


					range = [str rangeOfString:@"->"];
				}
				if (range.length<=0) {

					[self.mArrTemp addObject:str];

				}
			}


			self.vPop.hidden = NO;
			[self.table reloadData];
		}
			return NO;
		case 122:
		{
			UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"当天", @"三天", @"一周", nil];
			alertView.tag = 122;
			[alertView show];
		}
			return NO;
		case 123:
		{

			UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"已同步", @"待同步", @"已取消", nil];
			alertView.tag = 123;
			[alertView show];
		}
			return NO;
		case 222:
		{
			UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"当天", @"三天", @"一周", nil];
			alertView.tag = 222;
			[alertView show];
		}
			return NO;
		case 223:
		{

			UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"已同步", @"待同步", @"已取消", nil];
			alertView.tag = 223;
			[alertView show];
		}
			return NO;
			case 212:
		{
			[self.mViewInput resignFirstResponder];
			if (![self.mArrData4 objectForKey:@"ARBPL"]) {
				return NO;
			}
			self.mArrTemp = [NSMutableArray array];
			NSString *str = [self.mArrData4 objectForKey:@"ARBPL"];
			NSRange range = [str rangeOfString:@"->"];

			if (range.length<=0) {

				[self.mArrTemp addObject:str];
			}
			else
			{
				while (range.length>0)
				{
					[self.mArrTemp addObject:[str substringToIndex:range.location]];


					str = [str substringFromIndex:range.length + range.location];


					range = [str rangeOfString:@"->"];
				}
				if (range.length<=0) {

					[self.mArrTemp addObject:str];

				}
			}


			self.vPop.hidden = NO;
			[self.table reloadData];
		}
			return NO;
			case 213:
		{
			[self.mViewInput resignFirstResponder];

		}
			return NO;
  default:
			return YES;
			break;
	}
}

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
	self.mViewInput = textField;

	switch (textField.tag) {
  case 122:
		{
//			[textField resignFirstResponder];
		}
			break;

  default:
			break;
	}
}

- (void)textFieldDidEndEditing:(UITextField *)textField
{
	switch (textField.tag) {
  case kBaoGongDanViewControllerTag_tfDingDanHao:
		{

			m_hv1_bSearch = NO;
			m_hv1_tfDingDanHao = textField.text;
		}
			break;

  case 121:
		{
			m_hv2_tfDingDanHao = textField.text;
		}
			break;

  case 131:
		{
			m_hv3_tfDingDanHao = textField.text;
		}
			break;

  case 211:
		{
			m_hv4_bSearch = NO;
			m_hv4_tfDingDanHao = textField.text;
		}
			break;

  case 221:
		{
			m_hv5_tfDingDanHao = textField.text;
		}
			break;

  case 231:
		{
			m_hv6_tfDingDanHao = textField.text;
		}
			break;

  default:
			break;
	}
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
	switch (alertView.tag) {
  case 122:
		{
			switch (buttonIndex) {
				case 1:
				{
					self.hv2.tfTianShu.text = @"当天";
					m_hv2_tfTianShu = @"当天";
				}
					break;

				case 2:
				{
					self.hv2.tfTianShu.text = @"三天";
					m_hv2_tfTianShu = @"三天";
				}
					break;

				case 3:
				{
					self.hv2.tfTianShu.text = @"一周";
					m_hv2_tfTianShu = @"一周";
				}
					break;

				default:
					break;
			}
		}
			break;


  case 123:
		{
			switch (buttonIndex) {
				case 1:
				{
					self.hv2.tfZhuangTai.text = @"已同步";
					m_hv2_tfZhuangTai =@"已同步";
				}
					break;

				case 2:
				{
					self.hv2.tfZhuangTai.text = @"待同步";
					m_hv2_tfZhuangTai =@"待同步";
				}
					break;

				case 3:
				{
					self.hv2.tfZhuangTai.text = @"已取消";
					m_hv2_tfZhuangTai =@"已取消";
				}
					break;

				default:
					break;
			}
		}
			break;
		case 222:
		{
			switch (buttonIndex) {
				case 1:
				{
					self.hv5.tfTianShu.text = @"当天";
					m_hv5_tfTianShu = @"当天";
				}
					break;

				case 2:
				{
					self.hv5.tfTianShu.text = @"三天";
					m_hv5_tfTianShu = @"三天";
				}
					break;

				case 3:
				{
					self.hv5.tfTianShu.text = @"一周";
					m_hv5_tfTianShu = @"一周";
				}
					break;

				default:
					break;
			}
		}
			break;


  case 223:
		{
			switch (buttonIndex) {
				case 1:
				{
					self.hv5.tfZhuangTai.text = @"已同步";
					m_hv5_tfZhuangTai = @"已同步";
				}
					break;

				case 2:
				{
					self.hv5.tfZhuangTai.text = @"待同步";
					m_hv5_tfZhuangTai = @"待同步";
				}
					break;

				case 3:
				{
					self.hv5.tfZhuangTai.text = @"已取消";
					m_hv5_tfZhuangTai = @"已取消";
				}
					break;

				default:
					break;
			}
		}
			break;

  default:
			break;
	}
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
	[self.mViewInput resignFirstResponder];
}

- (void)QRCodeViewControllerDelegateFinish:(id)sender
{
	switch (self.mBaoGongDanViewControllerType) {
  case kBaoGongDanViewControllerType_SpareParts:
		{
			switch (self.mBaoGongDanViewControllerTab) {
				case kBaoGongDanViewControllerTab_WanGongBaoGong:
				{
					[self.tvSpareParts_WanGongBaoGong beginUpdates];
					self.hv1.tfDingDanHao.text = sender;
					m_hv1_tfDingDanHao = sender;
					[self.tvSpareParts_WanGongBaoGong endUpdates];
				}
					break;
					

				case kBaoGongDanViewControllerTab_JiLuChaXun:
				{
					[self.tvSpareParts_JiLuChaXun beginUpdates];
					self.hv2.tfDingDanHao.text = sender;
					m_hv2_tfDingDanHao = sender;
					[self.tvSpareParts_JiLuChaXun endUpdates];
				}
					break;
					

				case kBaoGongDanViewControllerTab_TongBuSheZhi:
				{
					[self.tvSpareParts_TongBuSheZhi beginUpdates];
					self.hv3.tfDingDanHao.text = sender;
					m_hv3_tfDingDanHao = sender;
					[self.tvSpareParts_TongBuSheZhi endUpdates];
				}
					break;
					
				default:
					break;
			}
		}
			break;
		case kBaoGongDanViewControllerType_Merchandiser:
		{
			switch (self.mBaoGongDanViewControllerTab) {
				case kBaoGongDanViewControllerTab_WanGongBaoGong:
				{

					[self.tvMerchandiser_WanGongBaoGong beginUpdates];
					self.hv4.tfDingDanHao.text = sender;
					m_hv4_tfDingDanHao = sender;
					[self.tvMerchandiser_WanGongBaoGong endUpdates];
				}
					break;


				case kBaoGongDanViewControllerTab_JiLuChaXun:
				{
					[self.tvMerchandiser_JiLuChaXun beginUpdates];
					self.hv5.tfDingDanHao.text = sender;
					m_hv5_tfDingDanHao = sender;
					[self.tvMerchandiser_JiLuChaXun endUpdates];
				}
					break;


				case kBaoGongDanViewControllerTab_TongBuSheZhi:
				{
					[self.tvMerchandiser_TongBuSheZhi beginUpdates];
					self.hv6.tfDingDanHao.text = sender;
					m_hv6_tfDingDanHao = sender;
					[self.tvMerchandiser_TongBuSheZhi endUpdates];
				}
					break;

				default:
					break;
			}
		}
			break;

  default:
			break;
	}
}


@end
